using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using NCS.Library.Utilities;
using NCS.Module.CMS.Library;
using NCS.Library;
using NCS.Module.CMS.Library.Distributions;
using NCS.Module.CMS.Library.Definitions;

namespace NCS.Module.CMS.Web.HomePage
{
    public partial class RightTopView : CMSWebControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            DataTable tbl = DistributionController.Distributions_GetContentByView(8, Convert.ToInt32(AppEnv.PortalId()));
            this.rpt.DataSource = tbl;
            this.rpt.DataBind();
        }

        protected void rptNewsMostViews_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                DataRowView currow = (DataRowView)e.Item.DataItem;
                HyperLink hplTitle = (HyperLink)e.Item.FindControl("hplTitle");

                hplTitle.Text = ConvertUtility.ToString(currow["Content_Headline"]);
                if (hplTitle.Text.Length > 50)
                    hplTitle.Text = hplTitle.Text.Substring(0, 47) + "...";

                hplTitle.NavigateUrl = BuildUrlByDistId((int)currow["Distribution_ID"], (int)currow["Distribution_ZoneID"]);
            }
        }
    }
}